package tool

import play.api.data.Form
import play.api.data.Forms._
import tool.Pojo._

/**
 * Created by yz on 16/9/2021
 */
object FormTool {

  val accountForm = Form(
    mapping(
      "account" -> text
    )(AccountData.apply)(AccountData.unapply)
  )

  val userForm = Form(
    mapping(
      "account" -> text,
      "password" -> text
    )(UserData.apply)(UserData.unapply)
  )

  val changePasswordForm = Form(
    mapping(
      "password" -> text,
      "newPassword" -> text
    )(ChangePasswordData.apply)(ChangePasswordData.unapply)
  )

  val sampleNameForm = Form(
    mapping(
      "sampleName" -> text
    )(SampleNameData.apply)(SampleNameData.unapply)
  )

  val sampleForm = Form(
    mapping(
      "id" -> number,
      "sampleName" -> text,
      "describe" -> text
    )(SampleData.apply)(SampleData.unapply)
  )

  val describeForm = Form(
    mapping(
      "describe" -> text
    )(DescribeData.apply)(DescribeData.unapply)
  )

  val idsForm = Form(
    mapping(
      "ids" -> list(number)
    )(IdsData.apply)(IdsData.unapply)
  )

  val idForm = Form(
    mapping(
      "id" -> number
    )(IdData.apply)(IdData.unapply)
  )

  val rangeForm = Form(
    mapping(
      "range" -> text
    )(RangeData.apply)(RangeData.unapply)
  )

  val pathForm = Form(
    mapping(
      "path" -> text
    )(PathData.apply)(PathData.unapply)
  )

  val idOpForm = Form(
    mapping(
      "id" -> optional(number)
    )(IdOpData.apply)(IdOpData.unapply)
  )

  val queryForm = Form(
    mapping(
      "method" -> text,
      "queryText" -> text,
      "db" -> text,
      "evalue" -> text,
      "wordSize" -> text,
      "maxTargetSeqs" -> text
    )(QueryData.apply)(QueryData.unapply)
  )

  val nameForm = Form(
    mapping(
      "name" -> text
    )(NameData.apply)(NameData.unapply)
  )

  val missionNameForm = Form(
    mapping(
      "missionName" -> text
    )(MissionNameData.apply)(MissionNameData.unapply)
  )

  val missionForm = Form(
    mapping(
      "missionName" -> text,
      "missionIntro" -> text,
      "db" -> text,
      "trim5" -> text,
      "trim3" -> text,
      "threadNum" -> number,
    )(MissionData.apply)(MissionData.unapply)
  )

  val missionIdForm = Form(
    mapping(
      "missionId" -> number
    )(MissionIdData.apply)(MissionIdData.unapply)
  )

  val fileNameForm = Form(
    mapping(
      "fileName" -> text
    )(FileNameData.apply)(FileNameData.unapply)
  )

  val missionIdOptionForm = Form(
    mapping(
      "missionId" -> optional(number)
    )(MissionIdOptionData.apply)(MissionIdOptionData.unapply)
  )


}
